package com.lb.shopguide.ui.view.chart;


import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lb.shopguide.R;

/**
 * Created by kang on 2018/1/17.
 */

public class LbMemberLegendLayout extends LinearLayout {
    private View viewColor1;
    private View viewColor2;
    private TextView tvColor1;
    private TextView tvColor2;
    private LinearLayout layoutColor2;

    public LbMemberLegendLayout(Context context) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.layout_member_legend_layout, this);
        viewColor1 = findViewById(R.id.view_color_1);
        viewColor2 = findViewById(R.id.view_color_2);
        tvColor1 = findViewById(R.id.tv_color_1);
        tvColor2 = findViewById(R.id.tv_color_2);
        layoutColor2 = findViewById(R.id.layout_color_2);
    }

    public LbMemberLegendLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public void setLine(int line) {
        if (line == 1) {
            viewColor1.setBackgroundResource(R.drawable.bg_no_buy_member);
            viewColor2.setBackgroundResource(R.drawable.bg_3_buy_member);
            tvColor1.setText("无购买的会员");
            tvColor2.setText("购买过3次的会员");
        } else if (line == 2) {
            viewColor1.setBackgroundResource(R.drawable.bg_1_buy_member);
            viewColor2.setBackgroundResource(R.drawable.bg_4_buy_member);
            tvColor1.setText("购买过1次的会员");
            tvColor2.setText("购买过4次及以上的会员");
        }else if(line == 3){
            viewColor1.setBackgroundResource(R.drawable.bg_2_buy_member);
            tvColor1.setText("购买过2次的会员");
            layoutColor2.setVisibility(GONE);
        }
    }
}
